//
//  AXFAddGoodsView.m
//  闪电超市
//
//  Created by 李典 on 16/11/19.
//  Copyright © 2016年 李典. All rights reserved.
//

#import "AXFAddGoodsView.h"

@interface AXFAddGoodsView ()
@property (weak, nonatomic) IBOutlet UILabel *shopNumLable;
@property (weak, nonatomic) IBOutlet UIButton *addShopNumBtn;
@property (weak, nonatomic) IBOutlet UIButton *minusShopNumBtn;

@end

@implementation AXFAddGoodsView

+ (instancetype)addGoodsView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"AXFAddGoodsView" owner:nil options:nil]lastObject];
}
- (void)awakeFromNib
{
    [super awakeFromNib];
    self.shopCount = 0;
}
- (void)setShopCount:(NSInteger)shopCount
{
    _shopCount = shopCount;
    _shopNumLable.text = @(shopCount).description;
    _minusShopNumBtn.hidden = (shopCount == 0);
    _shopNumLable.hidden = (shopCount == 0);
}


//  ➕号按钮
- (IBAction)addShopNumBtn:(UIButton *)sender {
    self.isPlus = YES;
    self.shopCount ++;
    
    self.model.btnSelect = YES;
    if ([self.delegate respondsToSelector:@selector(addGoodsViewWith:buyCount:)]) {
        [self.delegate addGoodsViewWith:self buyCount:self.shopCount];
        
            [[NSNotificationCenter defaultCenter] postNotificationName:@"addNumber" object:nil];
        
        }
}
//  ➖号按钮
- (IBAction)minusShopNumBtn:(UIButton *)sender {
    self.shopCount --;
    self.isPlus = NO;
    if ([self.delegate respondsToSelector:@selector(addGoodsViewWith:buyCount:)]) {
        [self.delegate addGoodsViewWith:self buyCount:self.shopCount];
        
            [[NSNotificationCenter defaultCenter] postNotificationName:@"minusNumber" object:nil];
        
    }
}



/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
